package org.lyl.taobao.service;

import org.lyl.taobao.api.IUserService;
import org.lyl.taobao.api.entity.User;
import org.lyl.taobao.api.utils.DruidConnectionUtils;
import org.lyl.taobao.dao.IUserDao;
import org.lyl.taobao.dao.impl.UserDaoImpl;

import java.util.List;

/**
 * @Author: Re
 * @Date: 2021/3/26 19:15
 */
public class UserServiceImpl implements IUserService {
    IUserDao iUserDao=new UserDaoImpl();
    DruidConnectionUtils druidConnectionUtils=new DruidConnectionUtils();
    public boolean insertUser(User user) {
        return iUserDao.insertUser(druidConnectionUtils.getConnection(),user);
    }

    public User registerUser(User user) {
        return iUserDao.registerUser(druidConnectionUtils.getConnection(),user);
    }

    public List<User> checkAllUser() {
        return iUserDao.checkAllUser(druidConnectionUtils.getConnection());
    }

    public List<User> checkUser(String userName) {
        return iUserDao.checkUser(druidConnectionUtils.getConnection(),userName);
    }

    public boolean deleteUser(String userName) {
        return iUserDao.deleteUser(druidConnectionUtils.getConnection(),userName);
    }

    public boolean updateUser(User user) {
        return iUserDao.updateUser(druidConnectionUtils.getConnection(),user);
    }

    public Integer userIdByC_Id(Integer c_Id) {
        return iUserDao.getUserIdByC_Id(druidConnectionUtils.getConnection(),c_Id);
    }

    public float getUserBalanceByUserId(Integer userId) {
        return iUserDao.getUserBalanceByUserId(druidConnectionUtils.getConnection(), userId);
    }

    public boolean reduceBalanceByUserId(float price, Integer userId) {
        return iUserDao.reduceBalanceByUserId(druidConnectionUtils.getConnection(),price,userId);
    }

    public boolean addBalanceByUserId(float price, Integer userId) {
        return iUserDao.addBalanceByUserId(druidConnectionUtils.getConnection(),price,userId);
    }

    public boolean addPhoto(String imgPath,User user) {
        return iUserDao.addPhoto(druidConnectionUtils.getConnection(),imgPath,user);
    }

}
